package com.golf.server.engine.phys;

import net.phys2d.math.Vector2f;
import net.phys2d.raw.Body;
import net.phys2d.raw.BodyList;
import net.phys2d.raw.CollisionEvent;
import net.phys2d.raw.CollisionListener;
import net.phys2d.raw.StaticBody;
import net.phys2d.raw.World;
import net.phys2d.raw.shapes.Box;


public class TestWorld implements CollisionListener
{

    
    
    
    public static void main(final String[] args)
    {
        TestWorld w = new TestWorld();
        w.run();
    
    
    }

    public void run()
    {
//        Vector2f[] p = new Vector2f[4];
//        p[0] = new Vector2f(0,0);
//        p[1] = new Vector2f(100,0);
//        p[2] = new Vector2f(100,100);
//        p[3] = new Vector2f(0,100);
        
        World w = new World(new Vector2f(0,0), 100);
        w.clear();
        w.setGravity(0,10);        
        w.addListener(this);
//        w.add(new Body(new Polygon(p), 10000000));
//        w.add(new Body(new Circle(4), 1);
//        w.add(source);

        Body body1 = new StaticBody("Course", new Box(120.0f, 120.0f));
        body1.setPosition(5.0f, 100);
        w.add(body1);
         
        Body body5 = new Body("weight", new Box(25.0f, 25.0f), 30);
        body5.setPosition(50, 40);
        w.add(body5);        
        
        for (int i = 0 ; i < 700 ; i++)
        {
            w.step();
            BodyList b = w.getBodies();
            for (int p = 0 ; p < b.size() ; p++)
            {
                Body v = b.get(p);
                if (v.getID() == 1)
                    System.out.println("body " + v.toString());
            }
        }
        
        
    }
    
    public void collisionOccured(CollisionEvent evt)
    {
        System.out.println(evt.getBodyA().toString());
        System.out.println(evt.getBodyB().toString());
        // TODO Auto-generated method stub
        
    }
    
}
